<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="../common.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>编辑管理员</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="${ctx}/css/public.css" media="all" />

</head>
<body class="childrenBody">
<form class="layui-form" style="width:90%;">

    <div class="layui-col-md9 layui-col-xs7">
        <div class="layui-form-item magt3">
            <label class="layui-form-label">用户名称</label>
            <div class="layui-input-block">
                <input type="hidden" value="${requestScope.admin.userId}" name="userId">
                <input type="text" class="layui-input userName" lay-verify="required" name="userName"  value="${requestScope.admin.userName}" placeholder="请输入用户名称">
            </div>
        </div>
    </div>

    <div class="layui-col-md9 layui-col-xs7">
        <div class="layui-form-item magt3">
            <label class="layui-form-label">用户手机号</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input userPhone" lay-verify="required" name="userPhone"  value="${requestScope.admin.userPhone}" placeholder="请输入用户手机号">
            </div>
        </div>
    </div>

        <div class="layui-col-md9 layui-col-xs7">
            <div class="layui-form-item magt3">
                <label class="layui-form-label">密码</label>
                <div class="layui-input-block">
                    <input type="password" class="layui-input userPwd"    name="userPwd"  value="" placeholder="请输入密码">
                </div>
            </div>
        </div>



    <div class="layui-form-item layui-row layui-col-xs12" style="margin-top: 20px;">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="sub">立即提交</button>
        </div>
    </div>

</form>
<script type="text/javascript" src="${ctx}/layui/layui.js"></script>
<script>

    layui.use(['form','layer','layedit','laydate','upload'],function(){
        var form = layui.form
        layer = parent.layer === undefined ? layui.layer : top.layer,
            laypage = layui.laypage,
            layedit = layui.layedit,
            $ = layui.jquery;

        form.on("submit(sub)",function(data){
            var subData = {};
            subData.userName = data.field.userName;
            subData.userPhone = data.field.userPhone;
            subData.userPwd = data.field.userPwd;
            subData.userId = data.field.userId;
            //弹出loading
            var index = top.layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});
            $.ajax({
                url: '${ctx}/users/saveUsers',
                type: 'post',
                async: false,
                data: subData,
                dataType: "json",
                success: function (res) {
                    if (res.code == 10200){
                        top.layer.close(index);
                        top.layer.msg("操作成功！",{icon: 6});
                        parent.location.reload();
                    }else {
                        top.layer.msg(res.message,{icon: 5});
                    }
                }, error: function () {
                    top.layer.msg("系统异常！", {icon: 6});
                    top.layer.close(index);
                }
            });
            return false;
        });
    });
</script>
</body>
</html>
